package com.zebra.base.msgcode;

import cn.hutool.core.util.StrUtil;

/**
 * @ClassName SysErrorCode
 * @Description TODO 描写类的含义
 * @Author 消魂钉
 * @Date 6/1 0001 9:16
 *
 */
public enum SysErrorCode implements MsgCode{

    ERROR("20000", "系统异常"),
    SYS_BUSY_ERROR("20001", "系统繁忙,请您稍候再试"),
    REQ_ERROR("20002", "请求地址或参数错误"),
    DB_ERROR("20003", "入库失败"),
    DATA_NOT_FOUND("20004", "数据不存在"),
    PARAM_VALID("20005", "参数校验未通过[{0}]"),
    PARAM_ILLEGAL("20006", "参数格式错误[{0}]"),
    FILE_PROCESS_ERROR("20007", "文件处理失败"),
    FILE_SAVE_FAILED("20008", "文件保存失败"),
    FILE_GET_FAILED("20009", "文件获取失败"),
    LOGIN_TIMEOUT("20010", "登录超时，请重新登录！"),
    NO_PERMISSION("20011", "无访问权限"),
    GATEWAY_NOT_FOUND_SERVICE("20012", "服务未找到"),
    GATEWAY_ERROR("20013", "网关异常"),
    GATEWAY_CONNECT_TIME_OUT("20014", "网关超时"),
    INVALID_TOKEN("20016", "无效token"),
    UPLOAD_FILE_SIZE_LIMIT("20017", "上传文件大小超过[{0}]限制"),
    DUPLICATE_PRIMARY_KEY("20018","唯一键冲突");

    private String code;
    private String msg;

    SysErrorCode(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    @Override
    public String getCode() {
        return this.code;
    }

    @Override
    public String getMsg() {
        return this.msg;
    }

    /**
     * java有序的格式化文本，使用{0}做为占位符
     * @param errorCode
     * @param msg
     * @return
     */
    public String getMsg(SysErrorCode errorCode,String... msg) {
        return StrUtil.indexedFormat(errorCode.getMsg(),msg);
    }

}
